﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ReferralTracker.Data.Entities;
using ReferralTracker.Data.Contexts;

namespace ReferralTracker.Data.Repositories {
    public class ReferralSiteRepository : Repository<ReferralSite> {

        public ReferralSiteRepository(IContext context)
            : base(context) {

        }

        public bool SiteExists(string rootUrl) {
            var query = (from r in _data
                         where r.RootUrl.Contains(rootUrl)
                         select r).FirstOrDefault();

            return (query != null);
        }

        public ReferralSite FindByKey(int Id) {
            return (from r in _data
                    where r.Id == Id
                    select r).FirstOrDefault();
        }

        public ReferralSite FindByRootUrl(string rootUrl) {
            return (from r in _data
                    where rootUrl.Contains(r.RootUrl)
                    select r).FirstOrDefault();
        }
    }
}
